package com.commerce.constellation;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import java.util.Timer;
import java.util.TimerTask;

public class WelcomeActivity extends AppCompatActivity {

    private int agb = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        TextView textView = findViewById(R.id.huanying);
        Timer timer = new Timer();

        //开个线程睡眠2.5秒
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(3500);
                    timer.cancel();
                    startActivity(new Intent(WelcomeActivity.this,LoginActivity.class));
                    finish();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        //星座app淡出
        timer.scheduleAtFixedRate(new TimerTask() {
            @SuppressLint("Range")
            @Override
            public void run() {
                agb += 12;
                if(agb>255){agb=255;}
                runOnUiThread(()->textView.setTextColor(Color.argb(agb,255, 255, 255)));

            }
        },0,150);
    }
}